<?php
namespace Admin\Controller;
use Think\Controller;
class ApplyJoinController extends CommonController {
    //加盟商申请列表
    public function index(){
        $map = '';
        $is_check = I('is_check');
        if($is_check  != ''){
            $map['status'] = $is_check;
        }

        $search_content = I('search_content');
        if($search_content  != ''){
            $where['user_name'] = array('like',"%$search_content%");
            $where['phone'] = array('like',"%$search_content%");
            $where['_logic'] = 'or';
            $map['_complex'] = $where;
        }

        $row = 10;
        $p = $_GET['p'] ? $_GET['p'] : 1;
        $count = M('apply_join')->where($map)->count();
        $Page = new \Think\Page($count,$row);
        $show = $Page->show();

        $applyList = M('apply_join')->where($map)->page($p,$row)->select();

        $this->assign('p',$p);
        $this->assign('show',$show);
        $this->assign('is_check',$is_check);
        $this->assign('search_content',$search_content);
        $this->assign('applyList',$applyList);
        $this->display();
    }

    //操作
    public function operate(){
        $operateResult = M('apply_join')->where(array('id'=>I('uid')))->save(array('status'=>I('status')));
        if($operateResult === false){
            $this->error('操作失败');
        }else{
            $this->success('操作成功',U('index',array('p'=>I('p'),'is_check'=>I('is_check'),'search_content'=>I('search_content'))));
        }
    }
}